package march.test_3_3;

import java.util.Scanner;

public class TestMain4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int len1 = str1.length();
        int len2 = str2.length();
        int m = 0;
        int n = 0;
        if(len1 >= len2) {
            int tmp = len1 - len2;
            int i = 0;
            while (i < tmp) {
                for(int j = i; j < len2; j++) {
                    int cur = j;
                    while (str1.charAt(j) == str2.charAt(j)) {
                        j++;
                    }
                    if(j - cur > m - n) {
                        m = j;
                        n = cur;
                    }
                }
                i++;
            }
        } else {
            int tmp = len2 - len1;
            int i = 0;
            while (i < tmp) {
                for(int j = i; j < len1; j++) {
                    int cur = j;
                    while (str1.charAt(j) == str2.charAt(j)) {
                        j++;
                    }
                    if(j - cur > m - n) {
                        m = j;
                        n = cur;
                    }
                }
                i++;
            }
        }
        System.out.println(str1.substring(n,m));
    }
}
